package com.qyer.search.storm.logging;

import org.apache.log4j.DailyRollingFileAppender;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.slf4j.helpers.FormattingTuple;
import org.slf4j.helpers.MessageFormatter;
import scala.util.parsing.combinator.testing.Str;

/**
 * Created by tangzheng on 16/1/28.
 */
public class TimeCostLogger extends StormLogger{
  private String FQCN = TimeCostLogger.class.getName();

  public TimeCostLogger(String fileName, String loggerName) {
    super(fileName, loggerName, "%d{ISO8601} [%t] %p %c %x - %m%n", Level.INFO);
  }

  @Override
  public void info(String str){
    logger.info(str);
  }

  public void info(String format, Object... argArray){
    if (logger.isEnabledFor(Level.INFO)) {
      FormattingTuple ft = MessageFormatter.arrayFormat(format, argArray);
      logger.log(FQCN, Level.INFO, ft.getMessage(), ft.getThrowable());
    }
  }
}
